package swingExtended.swingControlGroup;

import java.util.HashMap;
import java.util.Map;

/**
 *
 * @author g1wshimu
 */
public interface ISwingControlGroup<T extends  javax.swing.JComponent, V> {
    
    /**
     * Takes a snap shot of the values of all the controls. Can call the
     * method reset() later to restore all controls to their respective
     * value stored during this call to snapShot.
     */
    public void snapShot();

    /**
     * Resets all the text field to their respective values during the last 
     * snap shot point.
     */
    public void reset();

    /**
     * @param key a unique key that will be used to identify the given
     * JTextField
     * @param value the JTextField to be grouped
     * @throws IllegalArgumentException if the given key contains a special
     * separator value used for storing the text fields to a text file.
     * @return the previous JTextField, null if it did not exist.
     */
    public T put(String key, T component);

    /**
     * Returns the text stored in the JTextField pointed to by the given key.
     * 
     * @param key
     * @throws NullPointerException a JTextField with the given key does not
     * exist
     * @return 
     */
    public V getValue(String key);

    /**
     * Initializes all the text fields from the contents of the given text file. 
     * @param url the URL of the text file.
     * @throws FileNotFoundException if a text file at the given URL cannot
     * be found
     * @throws IOException if an exception is thrown while reading from the
     * file
     */
    public void loadFromMapping(Map<String, V> url);

    public Map<String, V> getMapping();
    
}
